HTML code
<textarea id="commentarea"
name="S1" cols="30" rows="5"></textarea>
C# code
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
conn.Open();
string insertcmnt = "insert into Comment(Comment) values(@comment)";
SqlCommand com = new SqlCommand(insertcmnt, conn);
com.Parameters.AddWithValue("@comment", TextBoxMode.MultiLine.ToString());
com.ExecuteNonQuery();
Response.Write("Commented successfully");
conn.Close();
Anonymous User
23-Dec-2014Hi jai
You are storing the name of the MultiLine value from the TextBoxMode enum. You should be referencing the textarea object. Try this
com.Parameters.AddWithValue("@comment", commentarea.Text);
Also, the textarea in the html is missing the runat attribute
<textarea id="commentarea" name="S1" cols="30" rows="5" runat="server"></textarea>